// 封装个人中心页相关接口
import request from '@/utils/request'

// 提交用户个人信息
export const submitUserInfoService = ({ id, phone, email, avatar }) => {
  return request({
    url: '/user',
    method: 'PATCH',
    data: {
      id,
      phone,
      email,
      avatar
    }
  })
}

// 获取用户的个人信息
export const getUserInfoService = (id) => {
  return request({
    url: `/user/${id}`,
    method: 'GET'
  })
}

// 获取用户的预约信息
export const getOrderService = ({ id, pageSize, page }) => {
  return request({
    url: `/order/${id}`,
    method: 'GET',
    params: {
      pageSize,
      page
    }
  })
}

// 提交用户的评价信息
export const submitRateService = (data) => {
  return request({
    url: '/evaluate',
    method: 'POST',
    data
  })
}

// 获取用户的评价信息
export const getRateService = ({ id, pageSize, page }) => {
  return request({
    url: `/evaluate/${id}`,
    method: 'GET',
    params: {
      pageSize,
      page
    }
  })
}

// 修改用户密码
export const changePasswordService = ({ id, oldPassword, newPassword }) => {
  return request({
    url: `/user/pwd/${id}`,
    method: 'PATCH',
    data: {
      oldPassword,
      newPassword
    }
  })
}
